@(nav: String, path: String, topArticles: List[Article], articles: List[Article], topViewArticles: List[Article], topReplyArticles: List[Article], page: Int, total: Int)(implicit request: RequestHeader)

@import utils.RequestHelper
@main(s"${App.siteSetting.name} - 社区分享", "article") {
<div class="main layui-clear">
  <div class="wrap">
    <div class="content">
      <div class="fly-tab">
        <div class="layui-tab layui-tab-brief">
          <ul class="layui-tab-title">
            <li> <a href="/articles?nav=0" @if(nav == "0"){class="layui-this"}>全部</a> </li>
            <li> <a href="/articles?nav=1" @if(nav == "1"){class="layui-this"}>最新回答</a> </li>
            <li> <a href="/articles?nav=2" @if(nav == "2"){class="layui-this"}>最新提问</a> </li>
            <li> <a href="/articles?nav=3" @if(nav == "3"){class="layui-this"}>尚未回答</a> </li>
            <li> <a href="/articles?nav=4" @if(nav == "4"){class="layui-this"}>精帖</a> </li>
          </ul>
        </div>
        <i class="layui-icon fly-search">&#xe615;</i>
      </div>

      @if(topArticles.nonEmpty){
      <ul class="fly-panel fly-list fly-list-top">
        @for(a <- topArticles){
        <li class="fly-list-li">
          <a href="/user/home?uid=@{a.author._id}" class="fly-list-avatar">
            <img src="@a.author.headImg" alt="">
          </a>
          <h2 class="fly-tip">
            <a href="/article/view?_id=@a._id">@a.title</a>
            @if(a.top){
            <span class="fly-tip-stick">置顶</span>
            }
            @if(a.recommended){
            <span class="fly-tip-jing">精帖</span>
            }
          </h2>
          <p>
            <span><a href="user/home.html">@a.author.name</a></span>
            <span>@utils.DateTimeUtil.toPrettyString(a.timeStat.createTime)</span>
            <span>@a.categoryName</span>
            <span class="fly-list-hint">
              <i class="iconfont" title="回答">&#xe60c;</i> @a.replies.size
              <i class="iconfont" title="人气">&#xe60b;</i> @a.viewStat.count
            </span>
          </p>
        </li>
        }
      </ul>
      }

      <ul class="fly-panel fly-list">
        @for(a <- articles){
        <li class="fly-list-li">
          <a href="/user/home?uid=@{a.author._id}" class="fly-list-avatar">
            <img src="@a.author.headImg" alt="">
          </a>
          <h2 class="fly-tip">
            <a href="/article/view?_id=@a._id">@a.title</a>
          </h2>
          <p>
            <span><a href="/user/home?uid=@{a.author._id}">@a.author.name</a></span>
            <span>@utils.DateTimeUtil.toPrettyString(a.timeStat.createTime)</span>
            <span><a href="/articles?path=@{a.categoryPath}&page=@page">@a.categoryName</a></span>
            <span class="fly-list-hint">
              <i class="layui-icon" title="收藏">&#xe600;</i> @a.collectStat.count
              <i class="iconfont icon-zan" title="点赞"></i> @a.voteStat.count
              <i class="iconfont" title="回答">&#xe60c;</i> @a.replies.size
              <i class="iconfont" title="人气">&#xe60b;</i> @a.viewStat.count
            </span>
          </p>
        </li>
        }
      </ul>

      <div style="text-align: center">
        <div class="laypage-main">
          <a href="/articles?page=@{page-1}" class="laypage-prev">上一页</a><span>@{if(articles.isEmpty){0}else{page}}/@{math.ceil(total/15.0).toInt}</span><a href="/articles?page=@{page+1}" class="laypage-next">下一页</a></div>
      </div>

    </div>
  </div>

  <div class="edge">
    @if(RequestHelper.isLogin){
    <div class="jie-add">
      <a href="/article/add" class="layui-btn layui-btn-big">分享文章</a>
      <a href="/user#article" class="layui-btn layui-btn-big layui-btn-normal" style="margin-left: 10px;">我的分享</a>
    </div>
    }
    <dl class="fly-panel fly-list-one">
      <dt class="fly-panel-title">近期热文</dt>
      @for(a <- topViewArticles){
      <dd>
        <a href="/article/view?_id=@{a._id}">@a.title</a>
        <span><i class="iconfont">&#xe60b;</i> @a.viewStat.count</span>
      </dd>
      }
    </dl>

    <dl class="fly-panel fly-list-one">
      <dt class="fly-panel-title">近期热议</dt>
      @for(a <- topReplyArticles){
      <dd>
        <a href="/article/view?_id=@{a._id}">@a.title</a>
        <span><i class="iconfont">&#xe60c;</i> @a.replyStat.count</span>
      </dd>
      }
    </dl>

    <div class="fly-panel fly-link">
      <h3 class="fly-panel-title">友情链接</h3>
      <dl>
        @for(l <- App.siteSetting.links){
        <dd>
          <a href="@l.url" target="@l.target">@l.title</a>
        </dd>
        }
      </dl>
    </div>
  </div>
</div>
}

<script>
</script>
